//
//  SettingViewController.m
//  QuickCure
//
//  Created by haoge on 16/9/10.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "SettingViewController.h"
#import "SettingTableViewCell.h"
#import "SuggestionsBoxViewController.h"
#import <SVProgressHUD.h>
@interface SettingViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //使用tablevView
    UITableView *SettingTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)];
    
    
    //去除多余的空行   !!
    SettingTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    
    //cell行号
    SettingTableView.rowHeight = 50;
    
    //添加
    [self.view addSubview:SettingTableView];
    
    //设置代理
    SettingTableView.delegate = self;
    SettingTableView.dataSource = self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    //返回组
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    //返回行
    
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //加载
    SettingTableViewCell *cell = [[SettingTableViewCell alloc]initWithSetting:indexPath];
    
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //cell闪
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    
    if (indexPath.row == 0) {
        [self.navigationController pushViewController:[[SuggestionsBoxViewController alloc]init] animated:YES];
      
    }
    if (indexPath.row == 1) {

    }
    if (indexPath.row == 2) {

    }
    if (indexPath.row == 3) {
        
        [self canceluser];
    }
    
    
}
//注销用户
- (void) canceluser
{
    
//    if (self.cancelBlock) {
//        self.cancelBlock();
//    }
    
    
    
    UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"确定要注销吗" preferredStyle:UIAlertControllerStyleActionSheet];
    
    //两个按键
    UIAlertAction* confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        
        [[NSNotificationCenter defaultCenter]postNotificationName:@"remove" object:self];
        
        
        
        
        // 返回到登陆界面
        [self.navigationController popViewControllerAnimated:YES];
        
    }];

    
    
    UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    
    //添加
    [alertController addAction:cancel];
    [alertController addAction:confirm];
    
    //添加
    [self.navigationController presentViewController:alertController animated:YES completion:nil];
}

@end






















